// SceneGraph.h: interface for the SceneGraph class.
//
//////////////////////////////////////////////////////////////////////

#if !defined SCENEGRAPH_H
#define SCENEGRAPH_H

#include "SceneObject.h"
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

class SceneObject;  //avoid a circular definition


class SceneGraph  
{
    SceneObject *root; 
      
  public:

	SceneGraph();
	virtual ~SceneGraph();
	
	void bindRoot(SceneObject *object) {  root = object; }

	void updateScene(SceneObject* sceneObject, float timeElapsed);
	void updateScene(float timeElapsed){updateScene(root,timeElapsed);}
	void renderScene(SceneObject* sceneObject, float timeElapsed);
	void renderScene(float timeElapsed) { renderScene(root, timeElapsed); }	
	void collideScene(SceneObject* caller, SceneObject* called, float timeElapsed);
	void collideScene(SceneObject* caller, float timeElapsed){collideScene(caller,root,timeElapsed);}
	void setSceneCamera(SceneObject* camera, float timeElapsed){
         setSceneCamera(root,camera,timeElapsed);
         camera->setCamera(timeElapsed);
         vector<SceneObject*> *vec = root->getChildrenObjects();
         int i=0; 
         vector<SceneObject*>::iterator it;  
         for (it=vec->begin(); it!=vec->end(); ++it){
             i++;
             cout<<"i: "<<i<<endl;
             if (*it == camera){
	            cout << "switching cam" << *it<<endl;
                rotate(vec->begin(),vec->begin()+i-1,vec->end());
             }
             else
	             cout<<"not cam"<<endl;
             }
         }
	void setSceneCamera(SceneObject* sceneObject, SceneObject* camera, float timeElapsed);
	
};

#endif // SCENEGRAPH_H
